<?php
function load_xml_from_url($url) {
	global $logger;
	$logger->info('Loading xml from url:' . $url);
	if(!@fopen($url, 'r')) {
		$logger->error('No xml @ ' . $url);
		return false;
	}

	$xml = @simplexml_load_file($url);
	if(!$xml) {
		$logger->error('Data could not be read from the server at ' . $url);
		return false;
	}
        return $xml;

}

function append_simplexml(&$simplexml_to, &$simplexml_from)
{
    foreach ($simplexml_from->children() as $simplexml_child)
    {
        $simplexml_temp = $simplexml_to->addChild($simplexml_child->getName(), (string) $simplexml_child);
        foreach ($simplexml_child->attributes() as $attr_key => $attr_value)
        {
            $simplexml_temp->addAttribute($attr_key, $attr_value);
        }
       
        append_simplexml($simplexml_temp, $simplexml_child);
    }
} 
?>
